import { isEmptyObj } from "@/utils/util";
export default {
  namespaced: true,
  state: {
    deviceTag: {}
  },
  getters: {
    deviceTag: state => {
      if (isEmptyObj(state.deviceTag)) {
        try {
          const deviceTag = localStorage.getItem("v3.deviceTag");
          state.deviceTag = JSON.parse(deviceTag);
        } catch (e) {
          console.error(e);
        }
      }
      return state.deviceTag;
    }
  },
  mutations: {
    setDeviceTag(state, deviceTag) {
      state.deviceTag = deviceTag;
      localStorage.setItem("v3.deviceTag", JSON.stringify(deviceTag));
    }
  }
};
